<template>
	<view class="page">
		<view class="title">
			5.15.uni.request发送网络请求
		</view>
		<view class="p">
			官网链接API
			<uni-link href="https://uniapp.dcloud.net.cn/api/request/request.html" text="发送网络请求"
				color="#007BFF"></uni-link>
		</view>
		<view class="p">
			推荐学习一下 <uni-link
				href="https://www.bilibili.com/video/BV1XW4y1v7Md/?spm_id_from=333.1387.search.video_card.click"
				text="Async教程 " color="#007BFF"></uni-link>
		</view>
		<view class="p">
			<view v-for="(item,index) in arss" :key="index" class="box">
				<image :src="item.banner[0].url" mode="widthFix" class="img" lazy-load></image>
				{{item.name}}
			</view>
		</view>

	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'

	let arss = ref([])
	// uni.request({
	// 	url: "https://env-00jxt1ebvd3g.dev-hz.cloudbasefunction.cn/network/party",
	// 	success: (res) => {
	// 		arss.value = res.data.data
	// 	}
	// })

	// uni.request({
	// 	url: "https://env-00jxt1ebvd3g.dev-hz.cloudbasefunction.cn/network/party",
	// }).then((res) => {
	// 	arss.value = res.data.data
	// })

	//常用方式
	async function request() {
		let res = await uni.request({
			url: "https://env-00jxt1ebvd3g.dev-hz.cloudbasefunction.cn/network/party"
		})
		arss.value = res.data.data
	}

	request()
</script>

<style lang="scss" scoped>
	.box {
		margin-bottom: 24rpx;
	}
</style>